<?php
//set style
$aCSS = array(assets('css/jquery.fancybox.css', true));
$aJS = array(assets('js/jquery.fancybox.pack.js', true));

$this->frontend_lib->setACss($aCSS);
$this->frontend_lib->setAJs($aJS);
?>

<div class="row" id="rao-vat-page" data-count-url="<?php echo page_url(RAOVAT_SLUG . '/count'); ?>">
    <div class="col-md-12 col-xs-12">
        <h2 class="title text-center">Rao vặt</h2>
        <h3 class="item-title clear-mgr clear-pad f20px"><?php echo $oRaoVat->getTitle(); ?></h3>
    </div>
</div>

<div class="row mgt15">
    <div class="col-md-8 col-xs-12">
        <div class="row mgt20">
            <div class="col-md-5 col-xs-12 media">
                <?php
                    $img_thumb = '';
                    $img_org   = '';
                    if($oRaoVat->getImage()!='' && image_exist('public/' . $oRaoVat->image_folder . '/' . RAOVAT_IMAGE_URL .$oRaoVat->getImage())) {
                        $img_thumb = raovat_upload($oRaoVat->getImage(), $oRaoVat->image_folder);
                        $img_org = raovat_upload($oRaoVat->getImage(), $oRaoVat->image_folder, false);
                    } else {
                        $img_thumb = "http://placehold.it/".urlencode('150x150&text=Hình đại diện');
                        $img_org = $img_thumb;
                    }
                ?>
                <a href="<?php echo $img_org; ?>" class="thumbnail fancybox no-bdr" title="<?php echo $oRaoVat->getTitle(); ?>">
                    <img class="img-responsive media-object sticky-item lazy" src="<?php echo assets('images/blank.gif', true); ?>" data-src="<?php echo $img_thumb; ?>" />
                </a>
            </div>
            <div class="col-md-7 col-xs-12">
                <p class="mgt20">
                    <strong>Danh mục : </strong>
                    <a href="<?php echo rao_vat_cate_url($oRaoVat->cate_slug); ?>"><?php echo $oRaoVat->cate_title; ?></a>
                </p>
                <p>
                    <span><i>Đăng ngày : <?php echo fdate_format($oRaoVat->getCreatedAt(), 'd/m/Y'); ?></i></span>
                </p>
                <p class="text-hyphens"><strong><?php echo $oRaoVat->getDescription(); ?></strong></p>
            </div>
        </div>
        <div class="clearfix"></div>
        <div id="raovat-content" class="text-hyphens"><?php echo $oRaoVat->getDetail(); ?></div>
    </div>

    <div class="col-md-4 col-xs-12 mgt5">
	   <div class="panel panel-default clear-radius">
            <div class="panel-body">
                <h2 class="item-title text-center clear-pad clear-mgr f16px">Liên hệ</h2>
                <p class="mgt20">Đăng bởi : <?php echo $oRaoVat->full_name; ?></p>
        		<p>Điện thoại : <?php echo $oRaoVat->phone; ?><?php echo($oRaoVat->home_phone!='')?' / '.$oRaoVat->home_phone:''; ?></p>
        		<p>Địa chỉ : <?php echo $oRaoVat->address; ?></p>
        		<p>Công ty : <?php echo $oRaoVat->company; ?></p>
        		<p>Email : <a href="mailto:<?php echo $oRaoVat->email; ?>"><?php echo $oRaoVat->email; ?></a></p>
        		<p>Skype : <a href="skype:<?php echo $oRaoVat->skype; ?>?chat"><?php echo $oRaoVat->skype; ?></a></p>
                <p>Nơi áp dụng : <?php echo $oRaoVat->place; ?></p>
            </div>
        </div>

        <div class="list-group clear-radius">
            <?php foreach($aCategories as $cate) { ?>
            <?php
            $activeClass = '';
            $activeIcon = '';
            if($oRaoVat->cate_slug==$cate->getSlug()){
                $activeClass = 'active';
                $activeIcon = "<i class='glyphicon glyphicon-chevron-right'></i>&nbsp;";
            }
            ?>
            <a class="list-group-item clear-radius <?php echo $activeClass; ?> clearRadius" href="<?php echo rao_vat_cate_url($cate->getSlug()); ?>">
                <?php echo $activeIcon . $cate->getTitle(); ?>
                <span class="badge raovat-cate" data-cate-id="cate-<?php echo $cate->getId(); ?>"></span>
            </a>
            <?php } ?>
        </div>
	</div>
</div>